﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

/// <summary>
/// Summary description for StockKeyFigure
/// </summary>
public class StockKeyFigure
{
  private const string STORED_PROCEDURE = "StockKeyFigure_Get";
  DatabaseManager db;
  MySqlDataReader reader;

  public string Id { get; set; }
  public int Year { get; set; }
  public double KI { get; set; }
  public double PE { get; set; }
  public double EPS { get; set; }
  public double PEGRatio { get; set; }

	public StockKeyFigure()
	{
    db = new DatabaseManager();
	}

  public void Load(string id, int year)
  {
    db.AddParameter("@id", id);
    db.AddParameter("@year", year);
    using (reader = db.ExecuteStoredProcedure(STORED_PROCEDURE))
    {
      while (reader.Read())
      {
        Id = reader.GetString("id");
        Year = Convert.ToInt32(reader.GetString("year"));
        KI = Convert.ToInt32(reader.GetString("KI"));
        PE = Convert.ToInt32(reader.GetString("PE"));
        EPS = Convert.ToInt32(reader.GetString("EPS"));
        PEGRatio = Convert.ToInt32(reader.GetString("PEG_ratio"));
      }
    }
  }
}